{% extends "dada/base.html" %}

{% load recurse %}

{% block title %}
	pastiche
{% endblock %}

{% block heading %}
	pastiche
{% endblock %}

{% block content %}

	<p>
		<img alt="add item" title="add item" src="/static/icons/page_white_add.png" />
		<img alt="add task" title="add task" src="/static/icons/cog_add.png" />
		<img alt="add event" title="add event" src="/static/icons/calendar_add.png" />
		<img alt="add note" title="add note" src="/static/icons/note_add.png" />
		<img alt="add link" title="add link" src="/static/icons/link_add.png" />
	</p>

	<p>private items: show <img src="/static/icons/key.png" border="0" style="vertical-align: middle" /> / hide <img src="/static/icons/key_delete.png" border="0" style="vertical-align: middle" /></p>

	{% if items %}
	<h1>recent items</h1>
		
		{% recurse item.children.all with items as item %}
		<ul>
			{% loop %}
			<li style="background-color: {% cycle '#eeeeee' '#dddddd' '#cccccc' '#dddddd' %}; list-style-type: none">
				{% comment %} TODO: use list-style-marker for type icons {% endcomment %}
				{% comment %} {{ level }} {{ item.title }} {{ item.children.count }} {% endcomment %}
				<a href="type" style="text-decoration: none">
					{% ifequal item.rating -2 %}
						<img src="/static/icons/thumb_down.png" />
						<img src="/static/icons/thumb_down.png" />
					{% endifequal %}
					{% ifequal item.rating -1 %}
						<img src="/static/icons/thumb_down.png" />
					{% endifequal %}
					{% ifequal item.rating 0 %}
					{% endifequal %}
					{% ifequal item.rating 1 %}
						<img src="/static/icons/thumb_up.png" />
					{% endifequal %}
					{% ifequal item.rating 2 %}
						<img src="/static/icons/thumb_up.png" />
						<img src="/static/icons/thumb_up.png" />
					{% endifequal %}
					
					{% if item.task %}
						<img src="/static/icons/cog.png" />
					{% else %}
						{% if item.event %}
							<img src="/static/icons/calendar.png" />
						{% else %}
							{% if item.note %}
								<img src="/static/icons/note.png" />
							{% else %}
								{% if item.link %}
									<img src="/static/icons/link.png" />
								{% else %}
									<img src="/static/icons/page_white.png" />
								{% endif %}
							{% endif %}
						{% endif %}
					{% endif %}
					
					<b> {{ item.title }} </b>

					{% if item.private %}
						<img src="/static/icons/lock.png" alt="private" title="private" />
					{% comment %}{% else %}
						<img src="/static/icons/lock_open.png" alt="public" title="public" />
					{% endcomment %}{% endif %}

{% comment %}
					{{ item.user }}
					
					{{ item.date }}
{% endcomment %}
					
						{% if item.task %}
							{% if item.task.done %}
								<img src="/static/icons/tick.png" />
							{% endif %}
							{% if item.task.due %}
								<img src="/static/icons/clock.png" />
								{{ item.task.due }}
							{% endif %}
						{% else %}
							{% if item.event %}
								<img src="/static/icons/clock.png" />
								{{ item.event.start }} - {{ item.event.stop }}
							{% else %}
								{% if item.note %}
									{{ item.note.text }}
								{% else %}
									{% if item.link %}
										{{ item.link.url }}
									{% endif %}
								{% endif %}
							{% endif %}
						{% endif %}
					</a>

						
					{% for annotation in item.annotations.all %}
						<a href="/note/{{ annotation.id }}">
							<img src="/static/icons/note.png" alt="{{ annotation.title }}" title="{{ annotation.title }}" />
						</a>
					{% endfor %}
					{% for note in item.notes.all %}
						<a href="/note/{{ note.id }}">
							<img src="/static/icons/note.png" alt="{{ note.title }}" title="{{ note.title }}" />
						</a>
					{% endfor %}
					{% for link in item.links.all %}
						<a href="/link/{{ link.id }}">
							<img src="/static/icons/link.png" alt="{{ link.title }}" title="{{ link.title }}" />
						</a>
					{% endfor %}
					<img src="/static/icons/tag_blue.png" />
					<img src="/static/icons/world.png" />
					
					<span style="font-style: oblique">
						<img alt="delete" title="delete" src="/static/icons/delete.png" />
						<img alt="add note" title="add note" src="/static/icons/note_add.png" />
						<img alt="add link" title="add link" src="/static/icons/link_add.png" />
					</span>
					
				{% child %}
			</li>
			{% endloop %}
		</ul>
		{% endrecurse %}


	{% else %}
		<p>No items are available.</p>
	{% endif %}

	<h1>Items</h1>
	{% if all_items %}
		<table border=1 cellspacing=0 cellpadding=3>
			<thead style="font-weight: bold">
				<td>id</td>
				<td>title</td>
				<td>rating</td>
				<td>private</td>
				<td>user</td>
				<td>created</td>
				<td>modified</td>
				<td>annotations</td>
				<td></td>
			</thead style="font-weight: bold">
			<tbody>
				{% for item in all_items %}
					<tr>
						<td>{{ item.id }}
							{% if item.node %}
								{% if item.task %}
									Task
								{% else %}
									{% if item.event %}
										Event
									{% endif %}
								{% endif %}
							{% else %}
								{% if item.note %}
									Note
								{% else %}
									{% if item.link %}
										Link
									{% endif %}
								{% endif %}
							{% endif %}
						</td>
						<td>{{ item.title }}</td>
						<td>
							<img src="/static/icons/thumb_down.png" border="0" style="vertical-align: middle" />
							{{ item.rating }}
							<img src="/static/icons/thumb_up.png" border="0" style="vertical-align: middle" />
						</td>
						<td>
							{% if item.private %}
								<img src="/static/icons/lock.png" alt="private" title="private" border="0" style="vertical-align: middle" />
							{% comment %}{% else %}
								<img src="/static/icons/lock_open.png" alt="public" title="public" border="0" style="vertical-align: middle" />
							{% endcomment %}{% endif %}
						</td>
						<td>{{ item.user }}</td>
						<td>{{ item.created }}</td>
						<td>{{ item.modified }}</td>
						<td>
							{% if item.annotations %}
								{{ item.annotations.all|length }}
							{% endif %}
						</td>
					</tr>
				{% endfor %}
			</tbody>
		</table>
	{% else %}
		<p>No items are available.</p>
	{% endif %}
{% endblock %}
